package com.yaorange.api;

import com.yaorange.nongjt.service.INjtCommoneServie;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.core.domain.entity.SysDictData;
import com.yaorange.system.service.ISysDictDataService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


@RestController
@RequestMapping("/api/common")
public class NjtCommonAPI {

    @Autowired
    private ISysDictDataService sysDictDataService;

    @Autowired
    private INjtCommoneServie commoneServie;

    // http://localhost:8080/api/common/queryDictType?dictType=produce_type
    @GetMapping("/queryDictType")
    public AjaxResult queryDictType(@Param("dictType") String dictType) {
        List<SysDictData> list = sysDictDataService.selectDictDataListByDictType(dictType);
        return AjaxResult.success(list);
    }

    // http://localhost:8080/api/common/upload
    @PostMapping("/upload")
    public AjaxResult upload(@RequestPart("file")MultipartFile multipartFile) {
        return AjaxResult.success(commoneServie.uploadFile(multipartFile));
    }
}
